<template>
  <div class="classify">
    <div class="top">
      <ul>
        <li><router-link to="/play/listen">听听</router-link></li>
        <li><router-link to="/play/recommend">推荐</router-link></li>
        <li><router-link to="/play/classify">分类</router-link></li>
      </ul>
    </div>
    <van-nav-bar>
      <template #left>
        <van-icon name="apps-o" size="18" @click="showpo" color="#333" />
      </template>
      <template #right>
        <van-icon name="ellipsis" size="18" color="#333" />
      </template>
    </van-nav-bar>
    <div class="types">
      <ul>
        <li v-for="(item, index) in list" :key="index" @click="detail(item.id)">
          <img :src="item.pic56x56Url" alt="" />
          <span>{{ item.name }}</span>
        </li>
      </ul>
    </div>
    <div class="music">
      <p><van-icon name="good-job-o" />音乐推荐</p>
      <ul>
        <li v-for="(item, index) in hotlist" :key="index">
          <img :src="item.picUrl" alt="" />
          <span>{{ item.copywriter }}</span>
        </li>
      </ul>
    </div>
    <div class="music move">
      <p><van-icon name="flower-o" />情感</p>
      <ul>
        <li v-for="(item, index) in hotlists" :key="index">
          <img :src="item.picUrl" alt="" />
          <span>{{ item.copywriter }}</span>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { reqTypeApi } from "../../../api/radio";
import { hotDj } from "../../../api/radio";
export default {
  data() {
    return {
      list: [],
      hotlist: [],
      hotlists: [],
    };
  },
  computed: {},
  watch: {},

  methods: {
    //  全局事件总线
    showpo() {
      this.$bus.$emit("showPopup");
    },
    //获取分类点他（16）
    async getTypes() {
      const result = await reqTypeApi();
      console.log(result);
      result.categories.splice(7, 1);
      result.categories.splice(12, 1);
      this.list = result.categories;
      console.log(this.list);
    },

    //获取热门电台
    async getHot() {
      //音乐推荐
      const num = parseInt(Math.random() * 10);
      const params = { limit: 6, offset: num };
      const result = await hotDj(params);
      console.log(result);
      if (result.code) {
        this.hotlist = result.djRadios;
      }
      //情感
      const agparams = { limit: 6, offset: num + 2 };
      const agresult = await hotDj(agparams);
      console.log(agresult);
      if (agresult.code) {
        this.hotlists = agresult.djRadios;
      }
    },
    //跳转详情页
    async detail(id) {
      this.$router.push({ path: `/classifydetail/${id}` });
    },
  },
  created() {
    this.getTypes();
    this.getHot();
  },
  mounted() {},
  components: {},
};
</script>
<style scoped>
.types ul {
  display: flex;
  flex-wrap: wrap;
}
.types ul li {
  text-align: center;
  width: 25%;
}
.types ul li img {
  height: 50px;
}
.types ul li span {
  display: block;
}
.music {
  padding-top: 40px;
}
.music ul {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
}
.music ul li {
  width: 30%;
  font-size: 10px;
}
.music p {
  padding-left: 10px;
  padding-bottom: 5px;
}
.music ul li img {
  width: 100%;
  border-radius: 10px;
}
.music ul li span {
  display: block;
  text-align: center;
}
.move {
  padding-bottom: 60px;
}
.top {
  width: 80%;
  height: 50px;
  line-height: 50px;
  position: absolute;
  top: -4px;
  left: 47px;
  z-index: 999;
}

.top ul {
  width: 100%;
  height: 50px;
  line-height: 50px;
  text-align: center;
  background-color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.top ul li {
  margin: 0 10px;
}
.top ul li:nth-of-type(3) a {
  color: black;
  font-size: 17px;
  font-weight: bold;
}
li:nth-of-type(3) a {
  position: relative;
}
li:nth-of-type(3) a:before {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 36px;
  height: 5px;
  border-radius: 5px;
  background: red;
}
</style>
